home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / owlbwcc.zip / BWCCMSBX.CPP < prev    next >
C/C++ Source or Header  |  1992-02-02  |  13KB  |  345 lines

  1. /**********************************************************************/
  2. /*                  BWCCMSBX.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 1/12/92                 */
  4. /*            This program demonstrates a main dialog box             */
  5. /*              with a menu and buttons that call all                 */
  6. /*      predefined BWCC message boxes and message beep functions.     */
  7. /*      BWCCMessageBox is easy to use.  It is a direct replacement    */
  8. /*          for the standard MessageBox command in Windows.           */
  9. /**********************************************************************/
  10. #include <owl.h>
  11. #include <dialog.h>
  12. #include "BWCC.h"                        // Needed for BWCC
  13. #include "bwccmsbx.h"                    // Equates for menu and buttons
  14.  
  15. class TDialog3Dialog : public TDialog    // Dialog class to add
  16.   {                     // processing for menu and
  17.   public:                 // button selections
  18.     TDialog3Dialog(LPSTR lpName)         // constructor calls
  19.       :TDialog(NULL,lpName)          // base class constructor.
  20.        {                                 // BWCCGetVersion activates
  21.        BWCCGetVersion();                 // BWCC library
  22.        }
  23.     virtual void HandleMenuAbortRetryIgnore(RTMessage Msg) // menu handlers
  24.       = [CM_FIRST + IDM_ABORTRETRYIGNORE];
  25.     virtual void HandleMenuIconAsterisk(RTMessage Msg)
  26.       = [CM_FIRST + IDM_ICONASTERISK];
  27.     virtual void HandleMenuIconExclamation(RTMessage Msg)
  28.       = [CM_FIRST + IDM_ICONEXCLAMATION];
  29.     virtual void HandleMenuIconHand(RTMessage Msg)
  30.       = [CM_FIRST + IDM_ICONHAND];
  31.     virtual void HandleMenuIconInformation(RTMessage Msg)
  32.       = [CM_FIRST + IDM_ICONINFORMATION];
  33.     virtual void HandleMenuIconQuestion(RTMessage Msg)
  34.       = [CM_FIRST + IDM_ICONQUESTION];
  35.     virtual void HandleMenuIconStop(RTMessage Msg)
  36.       = [CM_FIRST + IDM_ICONSTOP];
  37.     virtual void HandleMenuOK(RTMessage Msg)
  38.       = [CM_FIRST + IDM_OK];
  39.     virtual void HandleMenuOKCancel(RTMessage Msg)
  40.       = [CM_FIRST + IDM_OKCANCEL];
  41.     virtual void HandleMenuRetryCancel(RTMessage Msg)
  42.       = [CM_FIRST + IDM_RETRYCANCEL];
  43.     virtual void HandleMenuYesNo(RTMessage Msg)
  44.       = [CM_FIRST + IDM_YESNO];
  45.     virtual void HandleMenuYesNoCancel(RTMessage Msg)
  46.       = [CM_FIRST + IDM_YESNOCANCEL];
  47.     virtual void HandleMenuMessageBeep(RTMessage Msg)
  48.       = [CM_FIRST + IDM_MESSAGEBEEP];
  49.     virtual void HandleMenuMessageBeepLoop(RTMessage Msg)
  50.       = [CM_FIRST + IDM_MESSAGEBEEPLOOP];
  51.  
  52.     virtual void HandleButtonAbortRetryIgnore(RTMessage Msg)// button handlers
  53.       = [ID_FIRST + IDB_ABORTRETRYIGNORE];
  54.     virtual void HandleButtonIconAsterisk(RTMessage Msg)
  55.       = [ID_FIRST + IDB_ICONASTERISK];
  56.     virtual void HandleButtonIconExclamation(RTMessage Msg)
  57.       = [ID_FIRST + IDB_ICONEXCLAMATION];
  58.     virtual void HandleButtonIconHand(RTMessage Msg)
  59.       = [ID_FIRST + IDB_ICONHAND];
  60.     virtual void HandleButtonIconInformation(RTMessage Msg)
  61.       = [ID_FIRST + IDB_ICONINFORMATION];
  62.     virtual void HandleButtonIconQuestion(RTMessage Msg)
  63.       = [ID_FIRST + IDB_ICONQUESTION];
  64.     virtual void HandleButtonIconStop(RTMessage Msg)
  65.       = [ID_FIRST + IDB_ICONSTOP];
  66.     virtual void HandleButtonOK(RTMessage Msg)
  67.       = [ID_FIRST + IDB_OK];
  68.     virtual void HandleButtonOKCancel(RTMessage Msg)
  69.       = [ID_FIRST + IDB_OKCANCEL];
  70.     virtual void HandleButtonRetryCancel(RTMessage Msg)
  71.       = [ID_FIRST + IDB_RETRYCANCEL];
  72.     virtual void HandleButtonYesNo(RTMessage Msg)
  73.       = [ID_FIRST + IDB_YESNO];
  74.     virtual void HandleButtonYesNoCancel(RTMessage Msg)
  75.       = [ID_FIRST + IDB_YESNOCANCEL];
  76.     virtual void HandleButtonMessageBeep(RTMessage Msg)
  77.       = [ID_FIRST + IDB_MESSAGEBEEP];
  78.     virtual void HandleButtonMessageBeepLoop(RTMessage Msg)
  79.       = [ID_FIRST + IDB_MESSAGEBEEPLOOP];
  80.  
  81.     void DisplayStatus(int nStatus); // display status of buttons pressed
  82.                      // when within message boxes
  83.   };
  84. void TDialog3Dialog:: HandleMenuAbortRetryIgnore(RTMessage)
  85.   {
  86.   int nStatus;
  87.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  88.               "Title of Message Box",MB_ABORTRETRYIGNORE);
  89.   DisplayStatus(nStatus);
  90.   }
  91. void TDialog3Dialog:: HandleMenuIconAsterisk(RTMessage)
  92.   {
  93.   int nStatus;
  94.   nStatus = MessageBox(HWindow,"Message inside of Message Box",
  95.                "Title of Message Box",MB_ICONASTERISK);
  96.   DisplayStatus(nStatus);
  97.   }
  98. void TDialog3Dialog:: HandleMenuIconExclamation(RTMessage)
  99.   {
  100.   int nStatus;
  101.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  102.                "Title of Message Box",MB_ICONEXCLAMATION);
  103.   DisplayStatus(nStatus);
  104.   }
  105. void TDialog3Dialog:: HandleMenuIconHand(RTMessage)
  106.   {
  107.   int nStatus;
  108.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  109.                "Title of Message Box",MB_ICONHAND);
  110.   DisplayStatus(nStatus);
  111.   }
  112. void TDialog3Dialog:: HandleMenuIconInformation(RTMessage)
  113.   {
  114.   int nStatus;
  115.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  116.                "Title of Message Box",MB_ICONINFORMATION);
  117.   DisplayStatus(nStatus);
  118.   }
  119. void TDialog3Dialog:: HandleMenuIconQuestion(RTMessage)
  120.   {
  121.   int nStatus;
  122.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  123.                "Title of Message Box",MB_ICONQUESTION);
  124.   DisplayStatus(nStatus);
  125.   }
  126. void TDialog3Dialog:: HandleMenuIconStop(RTMessage)
  127.   {
  128.   int nStatus;
  129.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  130.                "Title of Message Box",MB_ICONSTOP);
  131.   DisplayStatus(nStatus);
  132.   }
  133. void TDialog3Dialog:: HandleMenuOK(RTMessage)
  134.   {
  135.   int nStatus;
  136.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  137.                "Title of Message Box",MB_OK);
  138.   DisplayStatus(nStatus);
  139.   }
  140. void TDialog3Dialog:: HandleMenuOKCancel(RTMessage)
  141.   {
  142.   int nStatus;
  143.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  144.                "Title of Message Box",MB_OKCANCEL);
  145.   DisplayStatus(nStatus);
  146.   }
  147. void TDialog3Dialog:: HandleMenuRetryCancel(RTMessage)
  148.   {
  149.   int nStatus;
  150.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  151.                "Title of Message Box",MB_RETRYCANCEL);
  152.   DisplayStatus(nStatus);
  153.   }
  154. void TDialog3Dialog:: HandleMenuYesNo(RTMessage)
  155.   {
  156.   int nStatus;
  157.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  158.                "Title of Message Box",MB_YESNO);
  159.   DisplayStatus(nStatus);
  160.   }
  161. void TDialog3Dialog:: HandleMenuYesNoCancel(RTMessage)
  162.   {
  163.   int nStatus;
  164.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  165.                "Title of Message Box",MB_YESNOCANCEL);
  166.   DisplayStatus(nStatus);
  167.   }
  168. void TDialog3Dialog:: HandleMenuMessageBeep(RTMessage)
  169.   {
  170.   MessageBeep(0);
  171.   }
  172. void TDialog3Dialog:: HandleMenuMessageBeepLoop(RTMessage)
  173.   {
  174.   int i;
  175.     for(i=0;i<100;i++)
  176.       MessageBeep(0);
  177.   }
  178.  
  179.  
  180. void TDialog3Dialog:: HandleButtonAbortRetryIgnore(RTMessage)
  181.   {
  182.   int nStatus;
  183.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  184.                "Title of Message Box",MB_ABORTRETRYIGNORE);
  185.   DisplayStatus(nStatus);
  186.   }
  187. void TDialog3Dialog:: HandleButtonIconAsterisk(RTMessage)
  188.   {
  189.   int nStatus;
  190.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  191.                "Title of Message Box",MB_ICONASTERISK);
  192.   DisplayStatus(nStatus);
  193.   }
  194. void TDialog3Dialog:: HandleButtonIconExclamation(RTMessage)
  195.   {
  196.   int nStatus;
  197.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  198.                "Title of Message Box",MB_ICONEXCLAMATION);
  199.   DisplayStatus(nStatus);
  200.   }
  201. void TDialog3Dialog:: HandleButtonIconHand(RTMessage)
  202.   {
  203.   int nStatus;
  204.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  205.                "Title of Message Box",MB_ICONHAND);
  206.   DisplayStatus(nStatus);
  207.   }
  208. void TDialog3Dialog:: HandleButtonIconInformation(RTMessage)
  209.   {
  210.   int nStatus;
  211.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  212.                "Title of Message Box",MB_ICONINFORMATION);
  213.   DisplayStatus(nStatus);
  214.   }
  215. void TDialog3Dialog:: HandleButtonIconQuestion(RTMessage)
  216.   {
  217.   int nStatus;
  218.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  219.                "Title of Message Box",MB_ICONQUESTION);
  220.   DisplayStatus(nStatus);
  221.   }
  222. void TDialog3Dialog:: HandleButtonIconStop(RTMessage)
  223.   {
  224.   int nStatus;
  225.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  226.                "Title of Message Box",MB_ICONSTOP);
  227.   DisplayStatus(nStatus);
  228.   }
  229. void TDialog3Dialog:: HandleButtonOK(RTMessage)
  230.   {
  231.   int nStatus;
  232.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  233.                "Title of Message Box",MB_OK);
  234.   DisplayStatus(nStatus);
  235.   }
  236. void TDialog3Dialog:: HandleButtonOKCancel(RTMessage)
  237.   {
  238.   int nStatus;
  239.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  240.                "Title of Message Box",MB_OKCANCEL);
  241.   DisplayStatus(nStatus);
  242.   }
  243. void TDialog3Dialog:: HandleButtonRetryCancel(RTMessage)
  244.   {
  245.   int nStatus;
  246.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  247.                "Title of Message Box",MB_RETRYCANCEL);
  248.   DisplayStatus(nStatus);
  249.   }
  250. void TDialog3Dialog:: HandleButtonYesNo(RTMessage)
  251.   {
  252.   int nStatus;
  253.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  254.                "Title of Message Box",MB_YESNO);
  255.   DisplayStatus(nStatus);
  256.   }
  257. void TDialog3Dialog:: HandleButtonYesNoCancel(RTMessage)
  258.   {
  259.   int nStatus;
  260.   nStatus = BWCCMessageBox(HWindow,"Message inside of Message Box",
  261.                "Title of Message Box",MB_YESNOCANCEL);
  262.   DisplayStatus(nStatus);
  263.   }
  264. void TDialog3Dialog:: HandleButtonMessageBeep(RTMessage)
  265.   {
  266.   MessageBeep(0);
  267.   }
  268. void TDialog3Dialog:: HandleButtonMessageBeepLoop(RTMessage)
  269.   {
  270.   int i;
  271.     for(i=0;i<100;i++)
  272.       MessageBeep(0);
  273.   }
  274.  
  275.  
  276. void TDialog3Dialog::DisplayStatus(int nStatus)
  277.   {
  278.   char szBuffer[40];
  279.   switch (nStatus)
  280.     {
  281.     case IDABORT:
  282.       wsprintf(szBuffer,"The Abort Button sent number %d",nStatus);
  283.       break;
  284.     case IDCANCEL:
  285.       wsprintf(szBuffer,"The Cancel Button sent number %d",nStatus);
  286.       break;
  287.     case IDIGNORE:
  288.       wsprintf(szBuffer,"The Ignore Button sent number %d",nStatus);
  289.       break;
  290.     case IDNO:
  291.       wsprintf(szBuffer,"The No Button sent number %d",nStatus);
  292.       break;
  293.     case IDOK:
  294.       wsprintf(szBuffer,"The OK Button sent number %d",nStatus);
  295.       break;
  296.     case IDRETRY:
  297.       wsprintf(szBuffer,"The Retry Button sent number %d",nStatus);
  298.       break;
  299.     case IDYES:
  300.       wsprintf(szBuffer,"The Yes Button sent number %d",nStatus);
  301.       break;
  302.     default:
  303.       wsprintf(szBuffer,"Out of Range Value  %d Passed",nStatus);
  304.     }
  305.     int i;
  306.     if (nStatus > 0)
  307.        BWCCMessageBox(HWindow,szBuffer,"Button Message",MB_OK);
  308.     else           //not enough memory to create message box
  309.        for (i=0;i<100;i++)MessageBeep(0);     // so beep instead
  310.   }
  311.  
  312.  
  313. /* ===================================================================== */
  314. class TDialog3App : public TApplication  // Application Class to contain
  315.   {                                      // the application
  316.   public:
  317.     TDialog3App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  318.         HANDLE hPrevInstance,            // base class constructor
  319.         LPSTR lpCmdLine, int nCmdShow)
  320.         :TApplication(lpName, hInstance,
  321.                   hPrevInstance,
  322.                   lpCmdLine, nCmdShow) {};
  323.  
  324.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  325.   };
  326.  
  327. void TDialog3App::InitMainWindow() // to initialize a dialog box
  328.   {                                // as the main window
  329.   MainWindow = new TDialog3Dialog("Main_Window_Dialog");
  330.   }                                // using message processing provided
  331.                    // by derived class
  332.  
  333. /**************************************************************************/
  334. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  335.            HANDLE hPrevInstance,          // windows to this program
  336.            LPSTR lpCmdLine , int nCmdShow)
  337.   {
  338.   TDialog3App Dialog3("Dialog Tester",hInstance,  // create instance of
  339.                hPrevInstance,             // the dialog application
  340.                lpCmdLine,nCmdShow);
  341.   Dialog3.Run();                                  // run it
  342.   return (Dialog3.Status);                        // exit
  343.   }
  344. /**************************************************************************/
  345.